import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { readFileSync } from 'fs';

// Read package.json to get metadata
const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));

export default {
  input: 'core/WRPlayer.js',
  output: [
    {
      file: 'dist/wrplayer.umd.js',
      format: 'umd',
      name: 'WRPlayer', // This will be the global variable name in browser environments
      sourcemap: true,
      globals: {
        // Specify globals for external dependencies if any, e.g., React
      }
    },
    {
      file: 'dist/wrplayer.esm.js',
      format: 'es',
      sourcemap: true
    }
  ],
  plugins: [
    resolve(), // Helps Rollup find external modules
    commonjs() // Converts CommonJS modules to ES6
  ],
  // If you have external dependencies that you don't want to bundle, list them here
  // For example:
  // external: ['react']
}; 